package ccpvspiral1;

import static org.junit.Assert.*;

import java.util.Arrays;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class CombinationTest {
	
	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testFindCombinationsCollectionOfT() {
		Integer[] firstTenIntegers = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
		List<Integer> listOfFirstTenIntegers = Arrays.asList(firstTenIntegers);
		List<List<Integer>> combinations = Combination.findCombinations(listOfFirstTenIntegers);
		printListOfListOfIntegers(combinations);
		System.out.println("size:  " + combinations.size());
	}

	@Test
	public void testFindCombinationsCollectionOfTInt() {
		Integer[] firstTenIntegers = new Integer[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
		List<Integer> listOfFirstTenIntegers = Arrays.asList(firstTenIntegers);
		List<List<Integer>> combinations = Combination.findCombinations(listOfFirstTenIntegers, 6);
		printListOfListOfIntegers(combinations);
		System.out.println("size:  " + combinations.size());
	}
	
	private void printListOfListOfIntegers(List<List<Integer>> combinations){
		for(List<Integer> list : combinations){
			printListOfIntegers(list);
		}
	}
	
	private void printListOfIntegers(List<Integer> combination){
		StringBuffer combinationString = new StringBuffer("{");
		for(int i : combination){
			combinationString.append(i + ",");
			
		}
		int length = combinationString.length();
		if(length > 1)
			//combinationString.substring(0, length - 2);
			combinationString.deleteCharAt(length - 1);
		combinationString.append("}");
		System.out.println(combinationString);
	}	

}
